﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Syntezator_mowy.Extras.Exception;

namespace Merger.Wav
{
    public class WavMerger : IMerger
    {
        public void margeFiles(string firstFile, string secondFile, string destinationFile)
        {
            WavFile firstWav = new WavFile(firstFile, false);
            if (File.Exists(secondFile))
            {
                WavFile secondWav = new WavFile(secondFile, false);

                if (firstWav.canMerge(secondWav))
                {
                    secondWav.mergeFile(firstWav);
                }
                else
                {
                    throw new FmtSubChunkFormatException();
                }
            }
            else
            {
                File.Copy(firstFile, destinationFile);
            }
        }

    }
}
